package org.wattdepot.cli;

import java.util.List;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.wattdepot.resource.source.jaxb.Source;
import org.wattdepot.util.tstamp.Tstamp;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * Test the carbonContent method to see if the power source and the
 * time stamp are valid.
 * @author Edwin Lim, Wing Ma Cheung
 *
 */
public class TestCarbonContent {
  private String command;
  private List<String> arguments;
  private String result = null;
  

  /**
   * Test the power source for valid input.
   * @throws Exception if the source is null or not valid
   */
  @Test
  public void testCarbonContentSource() throws Exception {
    CommandLineInterface cli = new CommandLineInterface();
    command = "carboncontent SIM_IPP 2009-11-15T12:00:00.000-10:00 sampling-interval 10";
    arguments = CommandLineInterface.deliminateCommand(command);
    result = arguments.get(1);
    Source source = cli.searchSource(result);
    assertEquals("Check source input", source.getName(), "SIM_IPP");   
  }
  
  /**
   * Test the time stamp for valid input.
   * @throws Exception if time stamp is invalid
   */
  @Test
  public void testCarbonContentTime() throws Exception {
    XMLGregorianCalendar timeStamp = null;
    XMLGregorianCalendar test = null;
    command = "carboncontent SIM_IPP 2009-11-15T12:00:00.000-10:00 sampling-interval 10";
    arguments = CommandLineInterface.deliminateCommand(command);
    result = arguments.get(2);
    timeStamp = Tstamp.makeTimestamp(result);
    test = Tstamp.makeTimestamp("2009-11-15T12:00:00.000-10:00");
    assertEquals("Check source input", timeStamp, test);   
  }
  
  
}
